<h2 class="pagesubsectionheader">What Can We Help You Find?</h2>

<div class="customproductdiv" style="width:300px;float:left;margin:0px;text-align:center;">
	<h3 style="margin-bottom:0px;"><a href="/../portable-solar-power-systems.html">Complete Solar Panel Power Kits</a></h3>
	<h3 style="margin-bottom:0px;">Our Most Popular...</h3>
	<?php $firstproduct = new wp_query('post_type=product&posts_per_page=1&p=22405');
		while($firstproduct->have_posts()) : $firstproduct->the_post();
		
			// Get The Product Image
			if (get_field('productFeaturedImage') != '') {
				$firstproductimage = get_field('productFeaturedImage');
			} else {
				$firstproductimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large');
				$firstproductimage = $firstproductimage[0];
			}
                                                                                
			// Get The Star Rating
			$count = $wpdb->get_var( $wpdb->prepare("
				SELECT COUNT(meta_value) FROM $wpdb->commentmeta
				LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
				WHERE meta_key = 'rating'
				AND comment_post_ID = %d
				AND comment_approved = '1'
				AND meta_value > 0
			", $post->ID ) );

			$rating = $wpdb->get_var( $wpdb->prepare("
				SELECT SUM(meta_value) FROM $wpdb->commentmeta
				LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
				WHERE meta_key = 'rating'
				AND comment_post_ID = %d
				AND comment_approved = '1'
			", $post->ID ) );

			$average = number_format($rating / $count, 2);
	?>
	
		<a href="<?php the_permalink(); ?>">
			<img src="<?php echo $firstproductimage ; ?>" alt="<?php the_title(); ?>" style="width:288px;height:288px;margin-bottom:10px;" />
		</a>
		<h3><a href="<?php the_permalink(); ?>">Complete 500W Portable AC Solar Power System</a></h3>
		<?php // echo '<div class="star-rating" style="margin-bottom:10px;" title="'.sprintf(__( 'Rated %s out of 5', 'woocommerce' ), $average).'"><span style="width:'.( ( $average / 5 ) * 100 ) . '%"><strong itemprop="ratingValue" class="rating">'.$average.'</strong> '.__( 'out of 5', 'woocommerce' ).'</span></div>'; ?>
                <?php include '/home/silicons/public_html/wp-content/themes/woostore/woocommerce/single-product/price.php'; ?>
		<p><a href="<?php the_permalink(); ?>" class="button">View &amp; Buy Now</a></p>
		<h3 style="margin-bottom:0px;">Or</h3>
		<p><a href="/../portable-solar-power-systems.html" class="button">View All Complete Kits</a></p>
	<?php endwhile; ?>
	<?php wp_reset_query(); ?>
	
</div>
<div class="customproductdiv" style="width:300px;float:right;margin:0px;text-align:center;">
	<h3 style="margin-bottom:0px;"><a href="/../shop/product-tag/diy-solar-kit/">Build-Your-Own Solar Panel Kits</a></h3>
	<h3 style="margin-bottom:0px;">Our Most Popular...</h3>
	<?php $secondproduct = new wp_query('post_type=product&posts_per_page=1&p=21583');
		while($secondproduct->have_posts()) : $secondproduct->the_post();
		
			// Get The Product Image
			if (get_field('productFeaturedImage') != '') {
				$secondproductimage = get_field('productFeaturedImage');
			} else {
				$secondproductimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large');
				$secondproductimage = $secondproductimage[0];
			}
                                                                                
			// Get The Star Rating
			$count = $wpdb->get_var( $wpdb->prepare("
				SELECT COUNT(meta_value) FROM $wpdb->commentmeta
				LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
				WHERE meta_key = 'rating'
				AND comment_post_ID = %d
				AND comment_approved = '1'
				AND meta_value > 0
			", $post->ID ) );

			$rating = $wpdb->get_var( $wpdb->prepare("
				SELECT SUM(meta_value) FROM $wpdb->commentmeta
				LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID
				WHERE meta_key = 'rating'
				AND comment_post_ID = %d
				AND comment_approved = '1'
			", $post->ID ) );

			$average = number_format($rating / $count, 2);
	?>
	
		<a href="<?php the_permalink(); ?>">
			<img src="<?php echo $secondproductimage ; ?>" alt="<?php the_title(); ?>" style="width:288px;height:288px;margin-bottom:10px;" />
		</a>
		<h3><a href="<?php the_permalink(); ?>">12W Build-Your-Own DIY Solar Panel Kit</a></h3>
		<?php // echo '<div class="star-rating" style="margin-bottom:10px;" title="'.sprintf(__( 'Rated %s out of 5', 'woocommerce' ), $average).'"><span style="width:'.( ( $average / 5 ) * 100 ) . '%"><strong itemprop="ratingValue" class="rating">'.$average.'</strong> '.__( 'out of 5', 'woocommerce' ).'</span></div>'; ?>
                <?php include '/home/silicons/public_html/wp-content/themes/woostore/woocommerce/single-product/price.php'; ?>
		<p><a href="<?php the_permalink(); ?>" class="button">View &amp; Buy Now</a></p>
		<h3 style="margin-bottom:0px;">Or</h3>
		<p><a href="/../shop/product-tag/diy-solar-kit/" class="button">View All DIY Panels</a></p>
	<?php endwhile; ?>
	<?php wp_reset_query(); ?>
</div>

<div style="width:100%;height:0px;clear:both;"></div>